﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CarlowPitBoy
{
    class KeyInfo
    {
        private bool _isPressed = false;
        private int _miliSecondsPressed = 0;
        private int _miliSecondsDepressed = 0;

        public KeyInfo parentKey = null;

        public bool isPressed
        {
            get
            {
                return _isPressed;
            }
        }

        public int miliSecondsPressed
        {
            get
            {
                return _miliSecondsPressed;
            }
        }

        public int miliSecondsDepressed
        {
            get
            {
                return _miliSecondsDepressed;
            }
        }

        /// <summary>
        /// Default Constructor
        /// </summary>
        public KeyInfo()
        {
        }

        /// <summary>
        /// Constructor if key is a child of another e.g F1 is a parent of functionKey
        /// </summary>
        /// <param name="parentKey">The key that this key belongs to</param>
        //public KeyInfo()
        //{
        //}

        public void pressed()
        {
            _isPressed = true;
            _miliSecondsDepressed = 0;
        }

        public void depressed()
        {
            _isPressed = false;
            _miliSecondsPressed = 0;
        }

        /// <summary>
        /// Gives length of time key has been pressed accurate
        /// to the value of how often it is updated
        /// </summary>
        /// <param name="miliSecondsSinceLastUpdate">How often this method is called by program</param>
        public void updateTimePressed(int miliSecondsSinceLastUpdate)
        {
            _miliSecondsPressed += miliSecondsSinceLastUpdate;
        }

        /// <summary>
        /// Gives length of time key has been depressed accurate
        /// to the value of how often it is updated
        /// </summary>
        /// <param name="miliSecondsSinceLastUpdate">How often this method is called by program</param>
        public void updateTimeDepressed(int miliSecondsSinceLastUpdate)
        {
            _miliSecondsDepressed += miliSecondsSinceLastUpdate;
        }        
    }
}
